package day01;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author feng
 * @Date 2021/7/19 16:10
 * 模拟倒计时 ,程序顺序执行。
 */
public class ThreadTest09 {

    public static void main(String[] args) throws InterruptedException {
        // 获取系统当前时间
        Date date = new Date(System.currentTimeMillis());
        boolean falg = true;

        int num = 10;
        while (true) {
            Thread.sleep(1000);
            System.out.println(new SimpleDateFormat("HH:mm:ss").format(date));
            --num;
            //更新系统时间
            date = new Date(System.currentTimeMillis());
            if (num < 0) {
                break;
            }
        }

    }

    public static void doStop() throws InterruptedException {
        int num = 10;
        while (true) {
            Thread.sleep(1000);
            System.out.println(num--);
            if (num < 0) {
                break;
            }

        }

    }
}
